<template>
  <a-modal v-model:visible.sync="store.state.user.add_status" title="设备工件信息新增" @ok="handleOk" okText="确认"
           cancelText="取消"
           @cancel="handle_cancel">
    <div class="row_box">
<!--      <div class="column_box">-->
<!--        <span>数采终端编号</span>-->
<!--        <a-input v-model:value="formState.params.uEquipmentCode" placeholder="请输入数采终端编号"/>-->
<!--      </div>-->
<!--      <div class="column_box">-->
<!--        <span>工件编号</span>-->
<!--        <a-input v-model:value="formState.params.partNo" placeholder="请输入工件名称"/>-->
<!--      </div>-->
      <div class="column_box">
        <span>工件名称</span>
        <a-input v-model:value="formState.params.partName" placeholder="请输入名称"/>
      </div>
      <div class="column_box">
        <span>工件图号</span>
        <a-input v-model:value="formState.params.partImgNo" placeholder="请输入工件图号"/>
      </div>
      <div class="column_box">
        <span>客户名称</span>
        <a-input v-model:value="formState.params.cusName" placeholder="请输入客户名称"/>
      </div>

<!--      <div class="column_box">-->
<!--        <span>生产日期</span>-->
<!--        <a-date-picker :default-value="formState.params.produceDate" v-model:value="formState.params.produceDate"-->
<!--                       show-time placeholder="请输入生产日期"/>-->
<!--      </div>-->
      <!--      <div class="column_box">-->
      <!--        <span>排序</span>-->
      <!--        <a-select-->
      <!--            placeholder="请选择排序"-->
      <!--            v-model:value="formState.params.sort"-->
      <!--            style="width: 100%"-->
      <!--            ref="select"-->
      <!--        >-->
      <!--          <a-select-option :value="0">倒序</a-select-option>-->
      <!--          <a-select-option :value="1">顺序</a-select-option>-->
      <!--        </a-select>-->
      <!--      </div>-->
    </div>
  </a-modal>
</template>

<script>
import {defineComponent, reactive} from "vue";
import {useStore} from "vuex"
import {edit_partInfo} from "@/api/device/partInfo"
import {message} from "ant-design-vue";

export default defineComponent({
  name: "add_work",
  setup(props, context) {
    const formState = reactive({
      params: {
        "id": 0,
        "partName": "",
        "partImgNo": "",
        "cusName": "",
        "createTime": ""
      }
    })

    /**
     * 状态管理
     *
     * */
    const store = useStore()

    /**
     * 确认新增
     *
     * */
    const handleOk = async () => {
      store.commit("SET_ADD_ROLE", false)

      const res = await edit_partInfo(formState.params)
      console.log(res)
      if (res.code === 1) {
        message.success("新增成功")
        formState.params = {}
        context.emit("re_flash:re_flash", "")
        return
      }
      message.success(res.message)

    }

    /**
     * 取消
     * */
    const handle_cancel = () => {
      store.commit("SET_ADD_ROLE", false)
    }

    return {
      formState,
      //状态管理
      store,
      // methods
      handleOk,
      handle_cancel
    }
  }
})
</script>

<style scoped lang="scss">

</style>
